<?php

namespace app\admin\validate;

use think\Validate;

class System extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     *
     * @var array
     */	
	protected $rule = [];
    
    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'
     *
     * @var array
     */	
    protected $message = [];
    //场景
    protected $scene = [];

    public function __construct()
    {
        $this->batch();
        $this->rule=[
            'menu_id'               => 'require|integer',
            'menu_pid'              => 'require|integer',
            'menu_name'             => ['require','regex'=>'/^[A-Z_a-z][A-Z_0-9\/a-z]*/'],
            'menu_title'            => 'require',
            'menu_icon'             => 'require',
            'menu_status'           => 'require|integer',
            'menu_order'            => 'require|integer',
            'menu_show'             => 'require|integer',
        ];
        $this->message=[

        ];
        $this->scene=[
            'menu_save'         =>['menu_pid','menu_name','menu_title','menu_status','menu_order','menu_show']
        ];
    }

    public function menu_save($p=''){
        //$this->scene['menu_save']=[];
        $this->message['menu_name.require'] = "菜单链接不能为空";
        $this->message['menu_name.require'] = "菜单链接格式不正确";
        return $this->scene('menu_save')->check($p);
    }
}
